<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-06 21:14:27
 * @LastEditTime: 2020-03-25 14:46:06
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>Hello APP</title>
	<link rel="stylesheet" type="text/css" href="../css/vant_new.css">
	<link rel="stylesheet" type="text/css" href="../css/base.css" />
	<script type="text/javascript" src="../script/jquery.js"></script>
	<script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
	<script type="text/javascript" src="../script/vue.min.js"></script>
	<script type="text/javascript" src="../script/vant_new.min.js"></script>
	<script type="text/javascript" src="../script/fastclick.js"></script>
	<script type="text/javascript" src="../script/base.js"></script>
	<script type="text/javascript" src="../script/db.js"></script>
	<style type="text/css">
		/* .head {
			 height: 70px!important;
			 line-height: 70px!important;
		 }
 
		 .body-no-bottom {
			 height: calc(100% - 70px);
			 position: relative;
		 } */
		.content {
			background: #fff !important;
		}

		.van-search {
			background: transparent !important;
		}

		.bg {
			background: #cd1b21;
			height: 68px;
		}

		.main {
			padding: 0 15px;
			margin-top: -60px;
		}

		.main>div {
			background: #fff;
			border-radius: 2px;
			padding: 15px;
			box-shadow: 0 0 5px rgb(200, 198, 198);
		}

		.main-1 {
			color: #3a3a3a;
			font-size: 15px;
		}

		.main-2 {
			line-height: 40px;
			color: #f95000;
			font-weight: 700;
			font-size: 22px;
			text-align: center;
		}

		.main-3 {
			font-size: 13px;
			text-align: center;
			padding: 10px 0;
			background: #f2f2f5;
			border-radius: 4px;
			color: #b0b0b0;
		}

		.main-3 .value {
			font-weight: 700;
			color: #f95000;
			font-size: 13px;
		}

		.img {
			width: 50px;
			height: 50px;
			text-align: center;
			border-radius: 25px;
			padding: 11px;
			position: relative;
		}

		.img img {
			height: 28px;
			vertical-align: middle;
		}

		.img-text {
			font-size: 14px;
			margin-top: 6px;
		}

		.notice {
			margin-top: 10px;
			background: #ffffff;
			padding: 10px;
			color: #3a3a3a;
		}

		.notice>div {
			position: relative;
		}

		.notice .notice-img {
			position: absolute;
			left: 0;
			top: 50%;
			width: 30px;
			padding-left: 10px;
			-webkit-transform: translateY(-50%);
			transform: translateY(-50%);
		}

		.notice .notice-img img {
			width: 20px;
		}

		.notice .notice-detail {
			padding: 0 30px 0 40px;
			line-height: 24px;
			font-size: 13px;
		}

		.notice .notice-detail .notice-info {
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.notice .notice-detail .store {
			color: #000;
		}

		.notice .notice-detail .result {
			color: #969799;
			margin-right: 4px;
		}

		.notice .notice-arrow {
			position: absolute;
			top: 50%;
			right: 0;
			-webkit-transform: translateY(-50%);
			transform: translateY(-50%);
		}

		/* .button .van-col {
			 margin-bottom: 10px;
		 } */

		.commonly-used {
			text-align: center;
			margin-top: 10px;
			background: #ffffff;
			color: #3a3a3a;
		}

		.label {
			height: 30px;
			line-height: 30px;
			padding: 0 10px 10px 10px;
			text-align: left;
			font-size: 15px;
		}

		.label * {
			vertical-align: middle;
		}

		.label img {
			width: 20px;
			margin-right: 5px;
		}



		.undeal {
			position: absolute;
			right: -4px;
			top: -4px;
			color: #fff;
			background: #cd1b21;
			width: 20px;
			height: 20px;
			line-height: 20px;
			text-align: center;
			border-radius: 100px;
			font-size: 13px;
		}

		.banner img {
			width: 100%;
			height: auto;
		}

		.head-index {
			color: #fff;
			font-weight: 700;
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			z-index: 9999;
			transition: all 0.4s;
		}

		.tz {
			margin: 20px 0;
			background: #fff;
			font-size: 13px;
			color: #9e9e9e;
			text-align: left;
			line-height: 50px;
			padding: 5px 10px;
			box-shadow: 0px 6px 12px #ebedf0;
		}

		.h-bg {
			height: 200px;
			background-image: linear-gradient(#1a92fd, #219ef5);
			position: relative;
			text-align: center;
		}

		.dd {
			position: absolute;
			left: 20px;
			right: 20px;
			bottom: -15px;
			background: #fff;
			padding: 20px;
			border-radius: 4px;
			box-shadow: 0 8px 12px #ebedf0;

		}

		.fw {
			font-weight: 700;
			font-size: 18px;
			margin-bottom: 10px;
		}

		.dtt {
			font-size: 13px;
			color: #9e9e9e;
		}

		.dw {
			font-size: 13px;
			font-weight: 500;
			color: #656565;
		}


		.bg {
			background: #efefef;
		}

		.bg .van-search__action i {
			color: #9e9e9e !important;
		}

		.van-search__action:active {
			background: transparent;
		}

		.kq {
			margin-top: 25px;
			padding-bottom: 5px;
			border-bottom: 5px solid #efefef;
		}

		.dk {
			padding: 5px 20px;
		}


		.q {
			margin-top: 10px;
		}

		.q span {
			width: 60px;
			text-align: center;
		}

		.zt {
			text-align: center;
			padding: 15px 0;
			font-weight: 700;
			font-size: 17px;
			border-bottom: 1px solid #ebedf0;
		}

		.d {
			font-size: 17px;
			padding-bottom: 10px;
			border-bottom: 1px solid #ebedf0;
		}

		.d>div {
			padding: 5px 10px;
		}

		.t {
			color: #9e9e9e;
		}

		.r {}

		.p {
			padding: 10px;
		}

		.van-uploader__preview-delete {
			position: absolute;
			top: -8px;
			right: -8px;
			color: #969799;
			font-size: 18px;
			background-color: #fff;
			border-radius: 100%;
		}

		.van-uploader__upload {
			width: 60px;
			height: 60px;
		}

		.van-uploader__preview-image {
			width: 60px;
			height: 60px;
		}

		.van-uploader__preview-delete {
			height: 20px;
		}

		.im {
			padding: 20px 10px 0 10px;
		}

		.im img {
			width: 100%;
		}

		.da {
			font-size: 40px;
			text-align: center;
			padding-bottom: 20px;
		}

		.dt {
			font-size: 16px;
			text-align: center;
			padding-bottom: 40px;
		}

		.c-1 {
			color: #ff943e;
		}

		.c-2 {
			color: #16be84;
		}

		.c-3 {
			color: #3296fa;
		}

		.lh {
			color:#3a3a3a!important;
			border: 1px solid #ffffff;
		}
		.clockType-1 {
            color: #25bd0c;
        }

        .clockType-2 {
            color: #dca31d;
		}
		.vm>*{
			vertical-align: middle;
		}
		.vm span{
			margin-right: 5px;
		}
		.unit{
			color: #9e9e9e;
			font-size: 14px;
			font-weight: 500;
			margin-left: 2px;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="init-full">
			<div class="head-index">
				<form action="">
					<van-search placeholder="" v-model="searchKey" shape="round" show-action @search="getSearch">
						<div slot="action" @click="openWinPage('vin')" style="padding: 0 10px;">
							<img id="kf" src="../image/vin-i.png" style="width: 26px;vertical-align: middle;" />
						</div>
					</van-search>
				</form>
			</div>
			<div class="body-no-bottom">
				<div class="content" onScroll="scrollMove()">

					<div class="h-bg">
						<div class="dd" @click="openWinPage('attendance')">
							<van-row>
								<van-col span="8">
									<div>
										<div class="fw">{{kqData.CQTS}}<span class="unit">天</span></div>
										<div class="dtt">出勤</div>
									</div>
								</van-col>
								<van-col span="8">
									<div>
										<div class="fw">{{kqData.QKCS}}<span class="unit">次</span></div>
										<div class="dtt">缺卡</div>
									</div>
								</van-col>
								<van-col span="8">
									<div>
										<div class="fw">{{kqData.CDCS}}<span class="unit">次</span></div>
										<div class="dtt">迟到</div>
									</div>
								</van-col>
							</van-row>
						</div>
					</div>

					<div class="kq">
						<div class="label">
							<img src="../image/used.png" />
							<span>考勤打卡</span>
						</div>
						<div class="dk">
							<van-row gutter="20">
								<van-col span="12">
									<van-button block :color="getDKColor(0)" @click="punchClock(1)"
										:disabled="!(lockStatusArray[0] == 0 && hour < 12)"
										:class="(lockStatusArray[0] == 1 && clockRecord.length)?'lh':''">
										<div v-if="lockStatusArray[0] == 0 && hour < 12">
											<span v-if="S_IsOut == 1">{{nowDate}}&nbsp;&nbsp;外勤打卡</span>
											<span v-if="S_IsOut == 0">{{nowDate}}&nbsp;&nbsp;{{getClockText(1)}}</span>
										</div>
										<div v-if="lockStatusArray[0] == 0 && hour > 12">缺卡</div>
										<div v-if="lockStatusArray[0] == 1 && clockRecord.length" class="vm">
											<span>已打卡</span>
											<van-tag v-if="getStatusText1(clockRecord[0])" :color="getColorText1(clockRecord[0])">{{getStatusText1(clockRecord[0])}}</van-tag>
											<van-tag v-if="getStatusText2(clockRecord[0])" :color="getColorText2(clockRecord[0])">{{getStatusText2(clockRecord[0])}}</van-tag>
										</div>
									</van-button>
								</van-col>
								<van-col span="12">
									<van-button block :color="getDKColor(1)" @click="punchClock(-1)"
										:disabled="!((lockStatusArray[0] == 1 && lockStatusArray[1] == 0) || ((lockStatusArray[0] == 0 && lockStatusArray[1] == 0) && hour > 12))"
										:class="(lockStatusArray[1] == 1 && clockRecord.length)?'lh':''">
										<div
											v-if="(lockStatusArray[0] == 1 && lockStatusArray[1] == 0) || ((lockStatusArray[0] == 0 && lockStatusArray[1] == 0) && hour > 12)">
											<span v-if="S_IsOut == 1">{{nowDate}}&nbsp;&nbsp;外勤打卡</span>
											<span v-if="S_IsOut == 0">{{nowDate}}&nbsp;&nbsp;下班打卡</span>
										</div>
										<div v-if="lockStatusArray[0] == 0 && hour < 12">无法打卡</div>
										<!-- <div v-if="lockStatusArray[1] == 0">缺卡</div> -->
										<div v-if="lockStatusArray[1] == 1 && clockRecord.length" class="vm">
											<span>已打卡</span>
											<van-tag v-if="getStatusText1(lockStatusArray[0] == 0?clockRecord[0]:clockRecord[1])"  :color="getColorText1(lockStatusArray[0] == 0?clockRecord[0]:clockRecord[1])">{{getStatusText1(lockStatusArray[0] == 0?clockRecord[0]:clockRecord[1])}}</van-tag>
											<van-tag v-if="getStatusText2(lockStatusArray[0] == 0?clockRecord[0]:clockRecord[1])"  :color="getColorText2(lockStatusArray[0] == 0?clockRecord[0]:clockRecord[1])">{{getStatusText2(lockStatusArray[0] == 0?clockRecord[0]:clockRecord[1])}}</van-tag>
										</div>
									</van-button>
								</van-col>
							</van-row>
						</div>
					</div>

					<div class="commonly-used">
						<div class="label">
							<img src="../image/used.png" />
							<span>我的功能</span>
						</div>
						<van-grid :column-num="4" :border="false">
							<van-grid-item v-for="row in usedList" @click="openPage(row)">
								<div class="img" :style="{background:row.AP_Colour}">
									<img :src="row.PIC_PH || '../image/module/module_default.png'" />
									<div class="undeal" v-show="unDealNum && row.APFunName == '下单记录'">{{unDealNum}}
									</div>
								</div>
								<div class="img-text">{{row.APFunName}}</div>
							</van-grid-item>
							<van-grid-item @click="openWinPage('moduleConfig')">
								<div class="img" style="background:#b5b5b5">
									<img src="../image/module/module-config.png" />
								</div>
								<div class="img-text">功能配置</div>
							</van-grid-item>
						</van-grid>
					</div>
				</div>
				<van-loading v-if="showLoading" />
			</div>
		</div>

		<van-popup v-model="showRemark" round :style="{ width: '80%' }">
			<div class="zt">{{punchClockType=='早退'?'确定要早退打卡吗?':'迟到打卡备注'}}</div>
			<div class="d">
				<div class="flex-box">
					<div class="t">打卡时间：</div>
					<div class="flex-main">{{FLD.getClockFormatDate()}}</div>
				</div>
				<div class="flex-box">
					<div class="t">打卡地点：</div>
					<div class="flex-main">{{S_TName}}</div>
				</div>
			</div>
			<div class="r">
				<van-field v-model="S_Remarks" rows="3" autosize type="textarea" placeholder="请填写打卡备注（选填）"
					style="font-size: 17px;"></van-field>
				<div class="p">
					<div>
						<div class="van-uploader">
							<div class="van-uploader__wrapper">
								<div class="van-uploader__preview" v-show="S_Path">
									<div class="van-image van-uploader__preview-image"
										style="overflow: hidden; border-radius: 4px;">
										<img :src="'http://' + S_Path" class="van-image__img"
											style="object-fit: cover;" />
									</div>
									<i class="van-icon van-icon-clear van-uploader__preview-delete"
										@click="S_Path = ''"></i>
								</div>
								<div class="van-uploader__upload" v-show="!S_Path" @click="chooseImg">
									<i class="van-icon van-icon-plus van-uploader__upload-icon"></i>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div>
				<van-row>
					<van-col span="12">
						<van-button type="default" block @click="showRemark = false"><span
								style="color: #cd1b21;">不打卡</span></van-button>
					</van-col>
					<van-col span="12">
						<van-button type="default" block @click="confirmDK"><span style="color: #cd1b21;">确定</span>
						</van-button>
					</van-col>
				</van-row>
			</div>
		</van-popup>


		<van-popup v-model="dkSuccess.show" round :style="{ width: '80%' }">
			<div class="im"><img :src="getDKImg()" /></div>
			<div class="da" :class="S_IsOut?'c-2':((dkSuccess.type == 1 || dkSuccess.type == -1)?'c-3':'c-1')">
				{{dkSuccess.date}}</div>
			<div class="dt" :class="S_IsOut?'c-2':((dkSuccess.type == 1 || dkSuccess.type == -1)?'c-3':'c-1')">
				{{dkSuccess.type > 0?'上班打卡成功':'下班打卡成功'}}</div>
			<div>
				<van-row>
					<van-col span="24">
						<van-button type="default" block @click="dkSuccess.show = false">
							<span style="color: #cd1b21;">我知道了</span></van-button>
					</van-col>
				</van-row>
			</div>
		</van-popup>

	</div>
</body>
<script type="text/javascript">
	var vm;

	function scrollMove() {
		if ($('.content').scrollTop() > 20) {
			$('.head-index').addClass('bg');
			$('#kf').attr('src', '../image/vin-ii.png');
		} else {
			$('.head-index').removeClass('bg')
			$('#kf').attr('src', '../image/vin-i.png');
		}
	}

	apiready = function () {
		//$('.init-full').show();

		DB.initDatabase(function () {
			DB.createTable(function () {
				
			});
		})

		var map = api.require('bMap');
		if (api.systemType == 'android') {
			map.setAgreePrivacy({
			agree:true
		});	
		}
		// if (api.systemType == 'ios') {
		map.initMapSDK(function (ret) { });
		// }

		api.addEventListener({
			name: 'smartupdatefinish'
		}, function (ret, err) {
			var systemType = api.systemType;
			if (systemType == "ios") {
				var value = ret.value;
				var extra = value[0];
				api.alert({
					title: '系统已经更新完成',
					msg: '点击确定关闭程序，重新打开后更新生效。',
					buttons: ['确定']
				}, function (ret, err) {
					if (ret.buttonIndex == "1") {
						api.closeWidget({
							id: 'A6023992839087', //这里改成自己的应用ID
							retData: {
								name: 'closeWidget'
							},
							silent: true
						});
					} else {
					}
				});
			}
		});

		api.addEventListener({
			name: 'setCommonFunctions'
		}, function (ret, err) {
			var moduleArray = ret.value.moduleArray;
			window.localStorage.setItem('usedList', JSON.stringify(moduleArray));

			vm.getModuleList();
		})

		api.addEventListener({
			name: 'refreshClock'
		}, function (ret, err) {
			vm.getclockRecord();
		})

		var FNScanner = api.require('FNScanner');
		var userInfo = FLD.getUserInfo();

		vm = new Vue({
			el: '#app',
			data: {
				showLoading: false,
				isRotate: false,
				serverIP: 'http://' + FLD.serverIP,
				searchKey: '',

				unDealNum: 0,
				statistics: [],
				noticeList: [],
				moduleList: [],
				usedList: [],
				kqData: '',

				nowDate: FLD.getFormatDate().split(' ')[1],
				hour: new Date().getHours(),
				todayDate: FLD.getFormatDate().split(' ')[0],
				baseData: '',
				clockRecord: [],
				lockStatusArray: [1, 1],      //0未打卡  1已打卡
				S_IsOut: 0,

				S_Path: '',
				S_Remarks: '',
				S_Longitude: '',
				S_Latitude: '',
				S_IsOut: 0,
				S_TName: '',
				showRemark: false,
				punchClockType:'',
				dkSuccess: {
					show: false,
					date: '',
					type: ''
				}

			},
			created: function () {
				var that = this;

				var appTop = parseInt(window.localStorage.getItem('safeAreaTop'));

				if (appTop) {
					$('.head-index').css({
						'padding-top': appTop + 'px',
						'height': appTop + 50 + 'px',
						'line-height': '40px'
					})
				}
				that.getbaseData();
				that.getKQData();
				that.getModuleList();

				setInterval(function () {
					that.nowDate = FLD.getFormatDate().split(' ')[1];
					that.hour = new Date().getHours();
				}, 1000)
			},
			methods: {

				getColorText1(data){
                    if(data.Status == 2){
                        return '#dca31d'
                    }else if(data.Status == -2){
                        return '#dca31d'
                    }else{
                        return '#3296fa'
                    }
                },
                getColorText2(data){
                    if(data.IsOut == 99){
                        return '#dca31d'
                    }else if(data.IsOut == 1){
                        return '#25bd0c'
                    }else{
                        return ''
                    }
                },
                getStatusText1(data){
                    if(data.Status == 2){
                        return '迟到'
                    }else if(data.Status == -2){
                        return '早退'
                    }else if(data.Status == 1){
                        return '上班'
                    }else if(data.Status == -1){
                        return '下班'
                    }
                },
                getStatusText2(data){
                    if(data.IsOut == 99){
                        return '补卡'
                    }else if(data.IsOut == 1){
                        return '外勤'
                    }else{
                        return ''
                    }
                },

				getDKImg() {
					var that = this;
					if (that.S_IsOut) {
						return ' ../image/oa/xb3.png';
					} else {
						if (that.dkSuccess.type == 1 || that.dkSuccess.type == -1) {
							return ' ../image/oa/xb2.png';
						} else {
							return ' ../image/oa/xb1.png';
						}
					}

				},
				chooseImg() {
					var that = this;

					var FNPhotograph = api.require('FNPhotograph');
					FNPhotograph.open({
						path: 'fs://',
						album: true,
						quality: 'medium'
					}, function (ret) {
						if (ret.eventType == 'takePhoto') {
							FNPhotograph.close();
							FLD.uploadFile('早退打卡', ret.imagePath, function (path) {
								that.S_Path = FLD.serverIP + path;
							})
						}
					});
				},
				confirmDK() {
					var that = this;
                    that.showRemark = false;
                    if(that.punchClockType == '早退'){
                        that.punchClock(-1, true);
                    }else{
                        that.punchClock(1, true);
                    }

				},
				updatePunchClock() {
					var that = this;
					that.$dialog.confirm({
						title: '提示',
						message: '确定要更新此次打卡记录吗?'
					}).then(() => {
						that.punchClock(-1);


					}).catch(() => {

					});
				},
				punchClock(index, status) {
					var that = this;
					if (that.showLoading == true) {
						return false;
					}

					that.showLoading = true;
					map.getLocation({
						accuracy: '10m',
						autoStop: true
					}, function (ret, err) {
						that.S_Longitude = ret.lon;
						that.S_Latitude = ret.lat;
						var rangeJSON = that.calLatLngByDistance(ret.lat, ret.lon, 500);
						if (ret.lon > rangeJSON.newLng1 && ret.lon < rangeJSON.newLng2 && ret.lat > rangeJSON.newLat1 && ret.lat < rangeJSON.newLat2) {
							that.S_IsOut = 0;
						} else {
							that.S_IsOut = 1;
						}
						map.getNameFromCoords({
							lon: ret.lon,
							lat: ret.lat
						}, function (ret, err) {
							that.S_TName = ret.address;

							if (index == 1) {
								if (that.getClockText(1) == '迟到打卡') {
									index = 2;
								}
							} else if (index == -1) {
								if (that.getClockText(2) == '早退打卡') {
									index = -2;
								}
							}
							if (index == -2 && !status) {
                                that.punchClockType = '早退';
                                that.showRemark = true;
                                that.showLoading = false;
                                return;
                            }else if(index == 2 && !status){
                                that.punchClockType = '迟到';
                                that.showRemark = true;
                                that.showLoading = false;
                                return;
                            }
							var obj = {
								S_NBranchID: that.baseData.BID,
								S_Status: index,
								S_Path: that.S_Path,
								S_Remarks: that.S_Remarks,
								S_Longitude: that.S_Longitude,
								S_Latitude: that.S_Latitude,
								S_IsOut: that.S_IsOut,
								S_TName: that.S_TName
							}
							FLD.ajax('APP_SXBDKJK_N', obj, function (res) {
								that.showLoading = false;
								that.punchClockType = '';
								that.getclockRecord();

								that.dkSuccess.show = true;
								that.dkSuccess.date = FLD.getClockFormatDate();
								that.dkSuccess.type = index;
							})
						});
					})

				},
				getDKColor(index) {
					var that = this;
					if (index == 0) {
						if (that.lockStatusArray[0] == 0 && that.hour < 12) {
							if (that.S_IsOut == 0) {
								if (that.getClockText(1) == '上班打卡') {
									return '#3296fa';
								} else {
									return '#ff943e';
								}
							} else {
								return '#16be84';
							}

						} else if (that.lockStatusArray[0] == 0 && that.hour > 12) {
							return '#a4a4a4';
						} else if (that.lockStatusArray[0] == 1 && that.clockRecord.length) {
							return '#ffffff'
						}
					} else {
						if ((that.lockStatusArray[0] == 1 && that.lockStatusArray[1] == 0) || ((that.lockStatusArray[0] == 0 && that.lockStatusArray[1] == 0) && that.hour > 12)) {
							if (that.S_IsOut == 0) {
								return '#3296fa';
							} else {
								return '#16be84';
							}

						} else if (that.lockStatusArray[1] == 0) {
							return '#a4a4a4';
						} else if (that.lockStatusArray[1] == 1 && that.clockRecord.length) {
							return '#ffffff'
						}
					}
				},
				getClockText(index) {
					var that = this;
					if (that.baseData) {
						if (index == 1) {
							if (FLD.getClockFormatDate() > that.baseData.BSDate) {
								return '迟到打卡';
							} else {
								return '上班打卡';
							}


						} else {
							if (FLD.getClockFormatDate() > that.baseData.BEDate) {
								return '下班打卡';
							} else {
								return '早退打卡';
							}

						}
					}

				},
				getbaseData() {
					var that = this;
					FLD.ajax('APP_HQGRKQXX_K', {}, function (res) {
						that.baseData = res.ds[0];
						that.getNewLocation();

						that.getclockRecord();
					})
				},
				getclockRecord() {
					var that = this;
					that.showLoading = true;
					var obj = {
						S_UserID: FLD.getUserInfo().UserID,
						S_SDate: that.todayDate,
						S_EDate: that.todayDate,
						S_NBranchID: that.baseData.BID
					}
					FLD.ajax('APP_SXBDKJL_N', obj, function (res) {
						that.showLoading = false;
						var clockRecord = [];
						var x = -1;
						var y = -1
						for (var i in res.ds) {
							if (res.ds[i].Status == 1 || res.ds[i].Status == 2) {
								x = i;
							}
							if (res.ds[i].Status == -1 || res.ds[i].Status == -2) {
								y = i;
							}
						}

						if (x > -1) {
							clockRecord.push(res.ds[x]);
						}
						if (y > -1) {
							clockRecord.push(res.ds[y]);
						}

						that.clockRecord = clockRecord;

						if (x == -1 && y == -1) {
							that.lockStatusArray = [0, 0];
						} else if (x > -1 && y == -1) {
							that.lockStatusArray = [1, 0];
						} else if (x == -1 && y > -1) {
							that.lockStatusArray = [0, 1];
						} else if (x > -1 && y > -1) {
							that.lockStatusArray = [1, 1];
						}



					})

				},
				getNewLocation() {
					var that = this;
					map.getLocation({
						accuracy: '10m',
						autoStop: false
					}, function (ret, err) {
						if (!that.baseData.Longitude || !that.baseData.Latitude) {
							that.S_IsOut = 0;
						} else {
							var rangeJSON = that.calLatLngByDistance(ret.lat, ret.lon, 500);
							if (that.baseData.Longitude > rangeJSON.newLng1 && that.baseData.Longitude < rangeJSON.newLng2 && that.baseData.Latitude > rangeJSON.newLat1 && that.baseData.Latitude < rangeJSON.newLat2) {
								that.S_IsOut = 0;
							} else {
								that.S_IsOut = 1;
							}
						}

					})
				},
				getKQData() {
					var that = this;
					var date1 = new Date();
					date1.setDate(1);

					var date_ = new Date();
					var currentMonth = date_.getMonth();
					var nextMonth = ++currentMonth;
					var nextMonthFirstDay = new Date(date_.getFullYear(), nextMonth, 1);
					var oneDay = 1000 * 60 * 60 * 24;
					var date2 = new Date(nextMonthFirstDay - oneDay)
					var obj = {
						S_XSDate: FLD.getFormatDate(date1).split(' ')[0],
						S_XEDate: FLD.getFormatDate(date2).split(' ')[0]
					}
					FLD.ajax('APP_YHKQTJRH', obj, function (res) {
						// console.log(JSON.stringify(res))
						that.kqData = res.ds[0];
					})
				},
				getSearch() {

				},
				getModuleList() {
					var that = this;
					FLD.ajax('AP_GetUserNM', {}, function (res) {
						that.moduleList = res.ds1;
						var usedList = [];
						var moduleArray = JSON.parse(window.localStorage.getItem('usedList'));
						if (moduleArray === null) {
							var localUsedList = [];
							for (var i in that.moduleList) {
								if (that.moduleList[i].IsMR == 1) {
									localUsedList.push(that.moduleList[i].APPFunID)
									usedList.push(that.moduleList[i])
								}
							}
							window.localStorage.setItem('usedList', JSON.stringify(localUsedList));
						}
						for (var i in that.moduleList) {
							for (var j in moduleArray) {
								if (that.moduleList[i].APPFunID == moduleArray[j]) {
									usedList.push(that.moduleList[i])
								}
							}
						}
						that.usedList = usedList;
					})
				},
				openScan() {
					var that = this;
					FNScanner.open({
						autorotation: true
					}, function (ret, err) {
						if (ret) {
							if (ret.eventType == 'success') {
								var obj = {
									S_Type: 60,
									S_Cont: '',
									S_BranchID: userInfo.S_BranchID,
									S_SXZ: '',
									S_StockID: userInfo.S_StockID,
									S_CargoID: userInfo.S_CargoID,
									S_BarCode: ret.content,
									S_PriceN: 0,
									S_ProductID: 0
								}
								FLD.ajax('AP_BasList', obj, function (res) {
									if (res.ds.length == 0) {
										layer.open({
											content: '当前二维码未查询到商品!',
											skin: 'msg',
											time: 2
										});
										return false;
									}
									var row = res.ds[0];
									api.openWin({
										name: 'inventory',
										url: 'inventory.html',
										reload: true,
										slidBackEnabled: false,
										allowEdit: false,
										pageParam: {
											searchKey: row.name
										}
									})

								})
							}
						} else {
							layer.open({
								content: '未查询到对应产品!',
								skin: 'msg',
								time: 2
							});
						}
					});
				},
				openPage(row) {
					var pageParam = {}
					if (row.Para) {
						var paraArray = row.Para.split(';');
						for (var i in paraArray) {
							var paraRowArray = paraArray[i].split('=');
							pageParam[paraRowArray[0]] = paraRowArray[1]
						}
					}
					pageParam.titleName = row.APFunName;
					if (row.FunType == '自定义') {
						if (row.AP_Link == 'trip/branchList') {
							var obj = {
								S_Type: 666,
								S_Cont: '',
								S_BranchID: userInfo.S_BranchID,
								S_SXZ: '',
								S_StockID: userInfo.S_StockID,
								S_CargoID: userInfo.S_CargoID,
								S_BarCode: '',
								S_PriceN: 0,
								S_ProductID: 0
							}
							FLD.ajax('AP_BasList', obj, function (res) {
								var filterResult = res.ds;
								if (filterResult.length == 1) {
									api.openWin({
										name: 'tripList',
										url: 'trip/tripList.html',
										reload: true,
										slidBackEnabled: false,
										allowEdit: false,
										pageParam: {
											branchData: filterResult[0]
										}
									})
								} else {
									api.openWin({
										name: row.AP_Link,
										url: row.AP_Link + '.html',
										reload: true,
										slidBackEnabled: false,
										allowEdit: row.AP_Link == 'vin' ? true : false,
										pageParam: pageParam
									})
								}
							})
						} else {
							api.openWin({
								name: row.AP_Link,
								url: row.AP_Link + '.html',
								reload: true,
								slidBackEnabled: false,
								allowEdit: row.AP_Link == 'vin' ? true : false,
								pageParam: pageParam
							})
						}

					} else if (row.FunType == '配置表单') {

						api.openWin({
							name: 'formConfig',
							url: 'common/formConfig.html',
							reload: true,
							slidBackEnabled: false,
							pageParam: pageParam
						})
					} else if (row.FunType == '配置列表') {
						api.openWin({
							name: 'formHistoricalDocuments',
							url: 'common/formHistoricalDocuments.html',
							reload: true,
							slidBackEnabled: false,
							pageParam: pageParam
						})
					} else if (row.FunType == '配置图表') {
						api.openWin({
							name: 'formConfigChart',
							url: 'common/formConfigChart.html',
							reload: true,
							slidBackEnabled: false,
							pageParam: pageParam
						})
					} else if (row.FunType == '配置报表') {
						api.openWin({
							name: pageParam.objName + '_0',
							url: 'common/formConfigReport.html',
							reload: true,
							slidBackEnabled: false,
							pageParam: pageParam
						})
					}

				},
				openWinPage(url) {
					var that = this;
					if (url == 'dataAggregation') {
						api.openWin({
							name: url,
							url: 'new_' + url + '.html',
							reload: true,
							slidBackEnabled: false,
							pageParam: {
								PID: that.statistics.PID,
								PName: that.statistics.PName
							}
						})
					} else {
						api.openWin({
							name: url,
							url: url + '.html',
							reload: true,
							slidBackEnabled: (url == 'pscan' ? true : false)
						})
					}

				},
				openWinHPage(type, tabActive) {
					api.openWin({
						name: 'historicalDocuments',
						url: 'common/historicalDocuments.html',
						reload: true,
						slidBackEnabled: false,
						pageParam: {
							type: type,
							tabActive: tabActive
						}
					})
				},
				calLatLngByDistance(originLat, originLng, distance) {
					//计算距离
					var getDistance = ($lng1, $lat1, $lng2, $lat2) => {
						const $earthRadius = 6367000;
						$lat1 = ($lat1 * Math.PI) / 180;
						$lng1 = ($lng1 * Math.PI) / 180;
						$lat2 = ($lat2 * Math.PI) / 180;
						$lng2 = ($lng2 * Math.PI) / 180;
						const $calcLongitude = $lng2 - $lng1;
						const $calcLatitude = $lat2 - $lat1;
						const $stepOne = Math.pow(Math.sin($calcLatitude / 2), 2) + Math.cos($lat1) * Math.cos($lat2) * Math.pow(Math.sin($calcLongitude / 2), 2);
						const $stepTwo = 2 * Math.asin(Math.min(1, Math.sqrt($stepOne)));
						const $calculatedDistance = ($earthRadius * $stepTwo);
						return Math.round($calculatedDistance);
					}
					let newLat1, newLat2, newLng1, newLng2

					let latDistance = getDistance(originLng, 1, originLng, 2);
					newLat1 = (originLat - (distance / latDistance)).toFixed(8);
					newLat2 = (originLat + (distance / latDistance)).toFixed(8);
					let lngDistance = getDistance(1, originLat, 2, originLat);
					newLng1 = (originLng - (distance / lngDistance)).toFixed(8);
					newLng2 = (originLng + (distance / lngDistance)).toFixed(8);

					return {
						newLat1: newLat1,
						newLat2: newLat2,
						newLng1: newLng1,
						newLng2: newLng2
					}

				}
			}
		})
	};
</script>

</html>